home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 October: Mac OS SDK / Dev.CD Oct 00 SDK1.toast / Development Kits / Mac OS / AIAT / Headers / Accessor / IAAccessor.h next >
Encoding:
Text File  |  1998-04-16  |  4.7 KB  |  151 lines  |  [TEXT/CWIE]

  1. // IAAccessor.h
  2. //    Copyright:    © 1994 - 1996 - 1997 - 1998 by Apple Computer, Inc., all rights reserved.
  3.  
  4. #pragma once
  5.  
  6. #ifndef IAAccessor_h
  7. #define IAAccessor_h
  8.  
  9. #pragma import on
  10.  
  11. #if PRAGMA_STRUCT_ALIGN
  12.     #pragma options align=power
  13. #endif
  14.  
  15. #include "IAIndex.h"
  16.  
  17. //#pragma IA_BEGIN_IMPORTS
  18. #include <time.h>
  19. //#pragma IA_END_IMPORTS
  20.  
  21. #pragma IA_BEGIN_EXPORTS
  22.  
  23. //// IAHit: base class for search results
  24. class IAHit : public IAObject {
  25. public:
  26.                     IAHit(IAIndex* i, IADoc* d);
  27.     virtual            ~IAHit();                            // deletes doc
  28.     
  29.     void SetIndex (IAIndex* idx) {index = idx;}
  30.     void SetDocument (IADoc* docu) {doc = docu;}
  31.     
  32.     IAIndex* GetIndex() const {return index;}
  33.     IADoc*     GetDocument() const {return doc;}
  34.     
  35. private:
  36.                     IAHit(IAHit&);                            // don't define a copy constructor
  37.     IAIndex*        index;
  38.     IADoc*            doc;
  39. };
  40.  
  41. //// IAProgressReport: base class for progress reports
  42. class IAProgressReport : public IAObject {
  43. public:
  44.                     IAProgressReport();
  45.     IA_INLINE        ~IAProgressReport() IA_INLINE_DEF()        // no-op dtor def
  46.     void SetPercent (float value) {percent = value;}
  47.     void SetIndex (IAIndex* idx) {index = idx;}
  48.     void SetDocument (IADoc* docu) {doc = docu;}
  49.  
  50.     float    GetPercent () const {return percent;}    
  51.     IAIndex* GetIndex() const {return index;}
  52.     IADoc*     GetDocument() const {return doc;}
  53.     
  54. private:
  55.     void*            operator new(size_t size);                // stack allocate only
  56.     // A number between 0.0 and 100.0, inclusive.
  57.     float            percent;
  58.     // When index is non-NULL, it names index currently being processed.
  59.     IAIndex*        index;
  60.     // When doc is non-NULL, it names the document being processed.
  61.     IADoc*            doc;
  62.  
  63. };
  64.  
  65.  
  66. class IAAccessor : public IAObject {
  67. public:
  68.     // Note: the destructor does *not* delete indices.
  69.                         IAAccessor(IAIndex** indices, uint32 indexCount, uint32 type);
  70.     virtual                ~IAAccessor();
  71.  
  72.     // If the initialization was previously stored then it is restored,
  73.     // otherwise it is computed from scratch, which may be slow for large indices.
  74.     // By default uses a named block in the TOC of indices[0].storage.
  75.     void                Initialize(IAStorage* storage = NULL, IABlockID block = 0);
  76.  
  77.     // Computes and stores initializations so that, if the index has not changed,
  78.     // the accessor may be initialized much faster the next time.
  79.     // Accessor should not be initialized when this is called.
  80.     void                StoreInitialization(IAStorage* storage = NULL, IABlockID block = 0);
  81.     
  82.     // True iff valid initializations are available for this accessor.
  83.     // When this is true, Initialize() will be fast, otherwise, if the storage is writable,
  84.     // StoreInitialization() might be called instead.
  85.     bool                IsInitializationValid(IAStorage* storage = NULL, IABlockID block = 0);
  86.  
  87.     void    SetIndices (IAIndex** indexes) {indices = indexes;}
  88.     void    SetIndexCount (uint32 count) {indexCount = count;}
  89.     void    SetAccessorType (uint32 type) {accessorType = type;}
  90.     
  91.     IAIndex**    GetIndices () const {return indices;}
  92.     uint32        GetIndexCount () const {return indexCount;}
  93.     uint32        GetAccessorType () const {return accessorType;}
  94.  
  95.     // If the initialization was previously stored and the index is not modified then
  96.     // it is restored, otherwise the initializations are updated regarding index 
  97.     // changes. By default uses a named block in the TOC of indices[0].storage.
  98.     void                Update(IAStorage* storage = NULL, IABlockID block = 0);
  99.     // Stores initializations so that, if the index has not changed,
  100.     // the accessor may be initialized much faster the next time.
  101.     // Accessor must have been initialized when this is called.
  102.     // This should not be called after a StoreInitialization call.
  103.     void                Store(IAStorage* storage = NULL, IABlockID block = 0);
  104.     
  105. protected:
  106.     bool                isConstructed;
  107.     bool                isInitialized;
  108.  
  109.     // Called to actually compute initializations.
  110.     virtual void        Initializing() = 0;
  111.  
  112.     // Called to save and restore initializations.
  113.     virtual IABlockSize    InitsSize() = 0;
  114.     virtual void        StoringInits(IAOutputBlock* output) = 0;
  115.     virtual void        RestoringInits(IAInputBlock* input) = 0;
  116.     
  117. // Called to update initializations.    
  118.     virtual void        UpdatingInits(IAInputBlock* input) = 0; 
  119.     virtual void        ExtendingInits() = 0; 
  120.  
  121.     // default constructor etc. so that this can be a virtual base class
  122.                         IAAccessor();
  123.     void                Constructing(IAIndex** indices, uint32 indexCount, uint32 type);
  124.  
  125. private:
  126.     IABlockSize            InitValidationSize();
  127.     void                StoreInitValidation(IAOutputBlock* output);
  128.     bool                RestoreInitValidation(IAInputBlock* input);
  129.     bool                UpdateInitValidation(IAInputBlock* input);
  130.     
  131.     IAIndex**            indices;
  132.     uint32                indexCount;
  133.  
  134.     uint32                accessorType;
  135. };
  136.  
  137. IAExceptionCode            IAAccessorAlreadyInitialized = 'VAAI';
  138. IAExceptionCode            IAAccessorNotInitialized = 'VANI';
  139. IAExceptionCode            IAAccessorInitInvalid = 'VAIV';
  140. IAExceptionCode            IAAccessorUpdateInvalid = 'VAUI';
  141.  
  142.  
  143. #pragma IA_END_EXPORTS
  144.  
  145. #if PRAGMA_STRUCT_ALIGN
  146.     #pragma options align=reset
  147. #endif
  148.  
  149. #pragma import reset
  150.  
  151. #endif